package com.boat.mybatis.controller;


import com.alibaba.druid.stat.DruidStatManagerFacade;
import com.boat.mybatis.dao.UserDAO;
import com.boat.mybatis.entity.User;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author : feng
 * @description: DruidStatController
 * @date : 2019-05-13 11:42
 * @version: : 1.0
 */
@RestController
public class UserController {

    @Resource
    UserDAO userDAO;

    @GetMapping("/druid/stat")
    public Object druidStat(){
        return DruidStatManagerFacade.getInstance().getDataSourceStatDataList();
    }

    @GetMapping("/list/user")
    public Object listUser() {
        return userDAO.listAll();
    }

    @PostMapping("/add")
    public Object addUser(@RequestBody User user) {
        return userDAO.add(user);
    }

    @GetMapping("/get")
    public Object getUser(String username){
        User res = userDAO.get(username);
        res= userDAO.getOne(username);
        return res;
    }

    @GetMapping("/getone")
    public Object getUserOne(@RequestParam String username){
        User res = userDAO.get(username);
        res= userDAO.getOne(username);
        return res;
    }

}
